//
//  UpLoadImageTool.m
//  Bees
//
//  Created by NowYouCanSee on 2019/1/3.
//  Copyright © 2019 xiaohan. All rights reserved.
//

#import "UpLoadImageTool.h"

@implementation UpLoadImageTool
+ (void)uploadImage:(UIImage*)image size:(CGSize)size complete:(void(^)(NSString*imageUrl,NSString*errorMsg))complete{
    UIImage *newImage = [image imageByResizeToSize:size];
    [NetworkManager uploadImagesWithURL:URL_ImageUpload parameters:@{} name:@"image" images:@[newImage] fileNames:nil imageScale:0.001 imageType:@"png" progress:^(NSProgress *progress) {
    } success:^(id responseObject) {
        XHBaseModel *response = [XHBaseModel modelWithDictionary:responseObject];
        if ([response.code isEqualToNumber:@200]) {
            if (StrValid(response.data)) {
                NSString *headimgurl = response.data;
                !complete?:complete(headimgurl,nil);
            }else{
                !complete?:complete(@"",nil);
            }
        }else{
            !complete?:complete(nil,response.message);
        }
    } failure:^(NSError *error) {
    }];
}
@end
